package com.balabala.gym_system.controller.app;


import com.balabala.gym_system.pojo.dto.ReservationListDto;
import com.balabala.gym_system.pojo.entity.ReservationInfo;
import com.balabala.gym_system.pojo.vo.ReservationVo;
import com.balabala.gym_system.service.ReservationListService;
import com.balabala.result.Result;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@Api(tags = "APP预约信息接口")
@RequestMapping("/app/ReservationList")
@CrossOrigin
public class ReservationAppController {

    @Autowired
    private ReservationListService reservationListService;


    //根据条件列表查询
    @PostMapping("/findListApp")
    @ApiOperation(value = "APP预约记录列表")
    public Result findList(ReservationListDto reservationListDto){

        //1.组装分页条件
        PageHelper.startPage(reservationListDto.getPage(),reservationListDto.getLimit());

        List<ReservationVo> reservationList = reservationListService.findByDto(reservationListDto);
        PageInfo<ReservationVo> pageInfo=new PageInfo<>(reservationList);

        //远程调用教练，场馆，场地
        return Result.ok(pageInfo.getList(),pageInfo.getTotal());

    }

    //根据id删除预约课程表
     @GetMapping("/deleteById")
     @ApiOperation(value = "APP删除预约记录")
     public Result deleteById(@RequestParam Long id){
        reservationListService.deleteReservation(id);
        return Result.ok();
     }


}
